package com.hl.toolkit.server.tycoin.user.slaveservice;

import com.tycoin.common.repository.AbstractRepository;
import com.tycoin.common.service.AbstractService;
import com.tycoin.user.slaveentity.TycoinUserLoginLog;
import com.tycoin.user.slaverepository.TycoinUserLoginLogRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(value = "slaveTransactionManager", readOnly = true)
public class TycoinUserLoginLogService   extends AbstractService<TycoinUserLoginLog, Long> {

	@Autowired
	private TycoinUserLoginLogRepository tycoinUserLoginLogRepository;
	
	
	@Override
	public AbstractRepository<TycoinUserLoginLog, Long> getRepository() {
 		return tycoinUserLoginLogRepository;
	} 
	

	public List<TycoinUserLoginLog> findByUserIdAll(long userId) {
 		return tycoinUserLoginLogRepository.findByUserIdAll(userId);
	}

	public List<TycoinUserLoginLog> findByUserId(long userId,int startNum,int endNum) {
		List<TycoinUserLoginLog> list= tycoinUserLoginLogRepository.findByUserIdAll(userId);
		if (list==null||list.size()<1)
			return null;
		return list.subList(startNum,endNum);
	}


	
	
	public  TycoinUserLoginLog  findByUserIdLast(long userId) {
		List<TycoinUserLoginLog> list= tycoinUserLoginLogRepository.findByUserIdAll(userId);
		TycoinUserLoginLog tycoinUserLoginLog=null;
		if(list!=null&&list.size()>0){
			tycoinUserLoginLog=list.get(0);
		}
		return tycoinUserLoginLog;
	}

	

}
